#pragma once
#include"RBTree.h"
namespace xsc
{
	template<class K,class V>
	class map
	{
		typedef pair<K, V> T;
	public:

		//虚函数，用于比较
		struct Map_Key
		{
			const K& operator()(const T& value)
			{
				return value.first;
			}
		};

		typedef typename RBTree<K, T, Map_Key>::iterator iterator;

		iterator begin()
		{
			return _tree.begin();
		}

		iterator end()
		{
			return _tree.end();
		}

		pair<iterator, bool> insert(const T& data)
		{
			return _tree.Insert(data);
		}

		//重载[]
		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = _tree.Insert(make_pair(key,V()));
			return ret.first->second;
		}

	private:
		RBTree<K, T, Map_Key> _tree;
	};
}